<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/12/24
  Time: 20:22
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" isELIgnored="false" language="java" %>
<html>
<head>
    <title>修改密码</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/layui/css/layui.css">
</head>
<body>
<form class="layui-form layui-form-pone">
    <div class="layui-form-item" >
        <label class="layui-form-label" style="width: 100px">
            当前密码
        </label>
        <div class="layui-input-inline" style="width: 200px">
            <input type="text" class="layui-input" id="password" autocomplete="off" placeholder="请输入当前密码" lay-verify="required" lay-reqText="密码不能为空">
        </div>
    </div>
    <div class="layui-form-item" >
        <div class="layui-inline">
            <label class="layui-form-label" style="width: 100px">
                修改密码
            </label>
            <div class="layui-input-inline" style="width: 200px">
                <input type="text" class="layui-input" id="nowpassword"   autocomplete="off" placeholder="请输入修改密码" lay-verify="required" lay-reqText="修改密码不能为空">
            </div>
        </div>
    </div>
    <div class="layui-form-item" >
        <div class="layui-inline">
            <label class="layui-form-label" style="width: 100px">
                确认修改密码
            </label>
            <div class="layui-input-inline" style="width: 200px">
                <input type="text" class="layui-input" id="againpassword" autocomplete="off" placeholder="再次输入修改密码" lay-verify="required" lay-reqText="确认密码不能为空">
            </div>
        </div>
    </div>
    <div class="layui-form-item" >
        <div class="layui-inline">
            <button class="layui-btn" id="searchBtn" type="button">确认</button>
        </div>
    </div>
</div>
</form>
<script src="${pageContext.request.contextPath}/resources/layui/layui.js"></script>
<script>
    layui.use(['form', 'layer', 'jquery', 'table'], function () {
        let form = layui.form
        let layer = layui.layer
        let $ = layui.jquery
        let table = layui.table;
        //项目根目录
        let cxt = "${pageContext.request.contextPath}";
        //修改密码
        $("#searchBtn").click(function () {
            let password = $("#password").val();
            let nowpassword = $("#nowpassword").val();
            let againpassword = $("#againpassword").val();
            if (password==nowpassword){
                layer.msg("修改密码不能和当前密码一致！")
                return false;
            }
            if (nowpassword!=againpassword){
                layer.msg("再次输入的密码和修改密码不一致！")
                return false;
            }
            layer.confirm("是否将修改密码？",function (d) {
                let param ={"service":"modifyPassword","nowpassword":nowpassword,"password":password};
                $.post(cxt+"/user.do",param,function (rs) {
                    //将业务消息展示
                    layer.msg(rs.msg);
                    if(rs.code!=200){
                        return;
                    }
                    parent.location.herf ="/user.do?service=loginout"
                    /*let param ={"service":"loginout"};
                    $.post(cxt+"/user.do",param,function (){

                    })*/
                })
            })

        })
    })
</script>
</body>
</html>
